package com.zijin.enumeration;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import com.zijin.constant.ErrorMsgConstant;
import com.zijin.exception.BaseException;
import lombok.Getter;
import lombok.Value;
import org.apache.commons.lang.ObjectUtils;

/**
 * @Title: SexEnum
 * @Author JWei Xu
 * @Package com.zijin.enumeration
 * @Date 2025/2/1 11:27
 * @description: 性别
 */

@Getter
public enum SexEnum {

    MAN(0,"男"),
    FEMALE(1,"女"),
    CONFIDENTIALITY(2,"保密"),
    OTHER(3,"其他"),
    ;

    @EnumValue
    private Integer code;

    @JsonValue
    private String value;

    SexEnum(Integer code,String value){
        this.code = code;
        this.value = value;
    }

    public static SexEnum getEnum(String value){
        for (SexEnum sexEnum : SexEnum.values()) {
            if(ObjectUtils.equals(sexEnum.getValue(),value)){
                return sexEnum;
            }
        }
        throw new BaseException(ErrorMsgConstant.NO_ENUMERATION_EXISTS+ value);
    }
}
